﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TeamNitro.Student
{
    public partial class Students_AddCDS : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {            
            List<DBManager_Jowie> dbJowie = DBManager_Jowie.GetCDSSubjects();
            for (int i = 0; i < dbJowie.Count(); i++)
            {
                ddlCDSName.Items.Add(dbJowie[i].CDSName);
            }
        }

        protected void btnCDSAdd_Click(object sender, EventArgs e)
        {
            List<DBManager_Jowie> dbJowie1 = DBManager_Jowie.GetCDSSubjects();

            DBManager_Jowie db = (DBManager_Jowie)Session["Student"];
            DBManager_Jowie dbJowie = new DBManager_Jowie();
            dbJowie.AdminNumber = db.AdminNumber;
            
            for (int i = 0; i < dbJowie1.Count(); i++)
            {
                if (ddlCDSName.SelectedValue == dbJowie1[i].CDSName)
                {
                    dbJowie.CDSCode = dbJowie1[i].CDSCode;
                    dbJowie.CDSName = dbJowie1[i].CDSName;
                    break;
                }
            }
            
            dbJowie.ChangeType = "Add";
            DBManager_Jowie.AddDropCDSSubjects(dbJowie);

            ddlCDSName.Items.Clear();
            for (int i = 0; i < dbJowie1.Count(); i++)
            {
                ddlCDSName.Items.Add(dbJowie1[i].CDSName);
            }
        }
    }
}